<?php 

class Crud_Form_Decorator_File extends Zend_Form_Decorator_File
{
    /**
     * Render a form file
     *
     * @param  string $content
     * @return string
     */
    public function render($content)
    {
    	$content = parent::render($content);
    	
    	$element = $this->getElement();
		$id = $element->getAttrib('fileId');
		
		$link = '';
    	if ($id) {
	    	$file = FilePeer::getInstance()->find($id)->current();
	    	if (!$file) {
	    		$name = $element->getName();
	    		throw new Exception("Cant get FileRow by id `$id` from element `$name`");
	    	}
	    	
	    	$url = $file->getUrl();
	    	$link .= "<a href='$url'><img src='$url' width='50' height='50' /></a> ";
    	}
    	
    	return $link . $content;
    }
}